/**
 * @param {number[]} prices
 * @return {number}
 */
export var maxProfit = function (prices) {
  let ans = 0
  let min = Number.MAX_VALUE
  for (let i = 0; i < prices.length; i++) {
    if (prices[i] < min) min = prices[i]
    ans = Math.max(ans, prices[i] - min)
  }
  return ans
}
